(function (vc) {

    vc.extends({
        data: {
            applyGoldWithdrawalInfo: {
                gwId: '',
                goldId: '',
                goldName: '',
                communityName:'',
                amount: '',
                applyAmount:'',
                applyUserName: '',
                applyUserTel: '',
                remark: '',
                bankNum:'',
                bankNumName:'',
                bankName:'',
            }
        },
        _initMethod: function () {

        },
        _initEvent: function () {

        },
        methods: {
            _openChooseGold: function () {
                vc.emit('chooseGold', 'openChooseGoldModel', $that.applyGoldWithdrawalInfo)
            },
            applyGoldWithdrawalValidate() {
                return vc.validate.validate({
                    applyGoldWithdrawalInfo: $that.applyGoldWithdrawalInfo
                }, {
                    'applyGoldWithdrawalInfo.goldId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "金币ID不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "30",
                            errInfo: "金币ID不能超过30"
                        },
                    ],
                    'applyGoldWithdrawalInfo.goldName': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "账户名称不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "30",
                            errInfo: "账户名称不能超过30"
                        },
                    ],
                    'applyGoldWithdrawalInfo.applyAmount': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "提现金额不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "10",
                            errInfo: "提现金额不能超过10"
                        },
                    ],
                    'applyGoldWithdrawalInfo.applyUserName': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "申请人不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "64",
                            errInfo: "申请人不能超过64"
                        },
                    ],
                    'applyGoldWithdrawalInfo.applyUserTel': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "申请人电话不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "11",
                            errInfo: "申请人电话不能超过11"
                        },
                    ],
                    'applyGoldWithdrawalInfo.remark': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "申请说明不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "512",
                            errInfo: "申请说明不能超过512"
                        },
                    ],

                });
            },
            saveGoldWithdrawalInfo: function () {
                if (!$that.applyGoldWithdrawalValidate()) {
                    vc.toast(vc.validate.errInfo);
                    return;
                }

                vc.http.apiPost(
                    '/gold.applyGoldWithdrawal',
                    JSON.stringify($that.applyGoldWithdrawalInfo),
                    {
                        emulateJSON: true
                    },
                    function (json, res) {
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            vc.goBack();
                            return;
                        }
                        vc.toast(_json.msg);

                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                        vc.toast(errInfo);

                    });
            },
        }
    });

})(window.vc);
